# -*- coding: utf-8 -*-
# @Time    : 2022/6/26 15:34
# @Author  : 我还能卷
# @FileName: read_excel.py
# @Software: PyCharm
import json

import openpyxl
from openpyxl.worksheet.worksheet import Worksheet


def read_excel(fpath, sheet):
    wb = openpyxl.load_workbook(fpath)
    sheet: Worksheet = wb[sheet]
    rows = list(sheet.values)
    keys = rows[0]
    values = rows[1:]
    new_list = [dict(zip(keys, i)) for i in values]
    return new_list


if __name__ == '__main__':

    items = read_excel(r'D:\smarthome_tesscases.xlsx', 'Unit')

    for d in items:

        head=json.loads(d['headers'])
        print(head)
        data = json.loads(d['data'])
        print(data)
        expe = json.loads(d['expected'])
        print(expe)



